package com.fenghongzhang.a18103.mvp.view;

import android.util.Log;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.fenghongzhang.a18103.R;
import com.fenghongzhang.a18103.adapter.FoodAdapter;
import com.fenghongzhang.a18103.entity.Food;
import com.fenghongzhang.a18103.mvp.contract.FoodContract;
import com.fenghongzhang.a18103.mvp.model.FoodModel;
import com.fenghongzhang.a18103.mvp.presenter.FoodPresenter;
import com.fenghongzhang.lib.mvp.view.BaseActivity;

import java.util.List;


public class MainActivity extends BaseActivity<FoodPresenter> implements FoodContract.IFoodView {
    private RecyclerView rv;
    private RecyclerView rv1;
    private static final String TAG = "MainActivity";
    @Override
    public void initAdapter(List<Food.DataBean> list) {
        //展示
        final FoodAdapter foodAdapter = new FoodAdapter(this, list);
//        FoodAdapter2 foodAdapter2 = new FoodAdapter2(R.layout.rv_layout, list, this);
        //rv的布局样式,可别忘了
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
//                rv.setLayoutManager(new StaggeredGridLayoutManager(1,StaggeredGridLayoutManager.VERTICAL));
                rv.setLayoutManager(new LinearLayoutManager(MainActivity.this,LinearLayoutManager.VERTICAL,false));
                rv.setAdapter(foodAdapter);
//                rv.setAdapter(foodAdapter2);
                rv1.setLayoutManager(new LinearLayoutManager(MainActivity.this,LinearLayoutManager.HORIZONTAL,false));
                rv1.setAdapter(foodAdapter);
            }
        });
    }
    //绑定布局
    @Override
    public int bindLayout() {
        return R.layout.activity_main;
    }
    @Override
    public void initView() {
        rv = (RecyclerView) findViewById(R.id.rv);
        rv1 = (RecyclerView) findViewById(R.id.rv1);
    }
    @Override
    public void initData() {
        //主持
        Log.i(TAG, "initData: aaa");
        mPresenter = new FoodPresenter(new FoodModel(),this);
//        DaggerFoodComponent.builder().foodMoudle(new FoodMoudle(this)).build().inject(this);
        mPresenter.getData();
    }



    @Override
    public void showToast(String s) {

    }
}
